#pragma once
#include "CCommand.h"

struct PlaneData
{
	gp_Pnt postion;
	gp_Dir normal;
	double size;
	Quantity_Color color;
};

class PlaneCommand : public BaseCommand
{
private:
	PlaneData m_data;

public:
	PlaneCommand(Handle(AIS_InteractiveContext) aisContext,
		const gp_Pnt& position,
		const gp_Dir& normal,
		double size,
		Quantity_Color color)
	{
		m_data.postion = position;
		m_data.normal = normal;
		m_data.size = size;
		m_data.color = color;

		m_aisContext = aisContext;
		m_aisObject = nullptr;
	}

	virtual bool Execute()
	{
		GC_MakePlane aPlaneMaker(m_data.postion, m_data.normal);
		Handle(Geom_Plane) geomPln = aPlaneMaker.Value();

		Standard_Real halfSize = m_data.size / 2;
		BRepBuilderAPI_MakeFace aFaceMaker(geomPln, -halfSize, halfSize, -halfSize, halfSize, Precision::Confusion());
		TopoDS_Face aFace = aFaceMaker.Face();

		m_aisObject = new AIS_Shape(aFace);
		m_aisObject->SetColor(m_data.color);
		m_aisContext->Display(m_aisObject, Standard_False);

		return true;
	}
};